﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace SlamDunk.CMS.DAL
{
    /// <summary>
    /// Channel数据访问层类（手写部分类）
    /// </summary>
    public partial class ChannelDal : IDAL.IChannelDal
    {
        #region 01.根据父Id获取栏目列表
        /// <summary>
        /// 根据父Id获取栏目列表
        /// </summary>
        /// <param name="pId">父Id</param>
        /// <returns>栏目列表</returns>
        public List<Model.Channel> GetModelList(int pId)
        {
            List<Model.Channel> list = new List<Model.Channel>();
            string sql = "SELECT * FROM Channels WHERE DelFlag = 0 AND PId = @PId";
            using (SqlDataReader reader = DbHelper.ExecuteReader(sql, new SqlParameter("@PId", pId)))
            {
                while (reader.Read())
                {
                    list.Add(ToModel(reader));
                }
            }
            return list;
        }
        #endregion
    }
}
